<template>
  <div class="container">
    <xy-table ref="table" :columns="columns" :api="api" :param="params">
      <template slot="addItem">
        <search-header :model="params" :on-search="onSearch"> </search-header>
      </template>
      <template #view="{ row }">
        <el-button type="text" @click="handleView(row)">
          {{ $language.local("View") }}
        </el-button>
      </template>
      <template #edit="{ row }">
        <template v-if="row.InvoiceBusinessStatus === 2">
          <el-button type="text" size="mini" @click="handleEdit(row)">
            {{ $language.local("补充发票信息") }}
          </el-button>
        </template>
        <span v-else hidden></span>
      </template>
    </xy-table>
    <el-dialog :visible.sync="viewDialogVisible" title="查看" width="81%">
      <invoice-table :invoce="viewData"></invoice-table>
    </el-dialog>
  </div>
</template>

<script>
import API from "../../plugins/api";
import InvoiceTable from "./InvoiceTable.vue";
export default {
  components: {
    "invoice-table": InvoiceTable,
  },
  data() {
    return {
      viewDialogVisible: false,
      api: new API("/api/invoice/"),
      columns: {
        // MID: 109,
        //    SID: 4,
        MerchantName: "湖南格凡安信科技有限公司",
        ServiceProviderName: "湖南好捷科技有限公司",
        // RechargeAmount: 704112.02,
        // Amount: 704112.02,
        // SPName: "",
        InvoiceTaxAmount: "",
        Amount: "",
        // sumpayamount: "",
        // InvoiceBlanceAmount: 0,
        wlgs: "",
        wldh: "",
        InvoiceBusinessStatus: "",
      },
      params: {
        SID: "",
        BeginDate: "",
        EndDate: "",
        InvoiceBusinessStatus: "",
      },
      viewData: {},
      formKeys: {
        ServiceProviderName: "湖南好捷科技有限公司",
        MerchantName: "广州腾云信息科技有限公司",
        // InvoiceBusinessStatus: 2,
        InvoiceBusinessStatusName: "已通过待开票",
        Indate: "2021-06-17T15:59:14",
        // ApplicationTime: "2021-06-17T15:59:14",
        Invoicesubject: "信息技术服务软件开发服务",
        Amount: 11342.36,
        Rate: 0,

        TaxAmount: 723.98,
        InvoiceTaxAmount: 12066.34,
        InvoiceType: "增值税普通发票",

        InvoiceCode: "",
        InvoiceNumber: "",
        wlgs: "",
        wldh: "",
        Remarks: "",

        // InvoicesubjectId: 0,
        // unioninvoice: 0,
        // MerchantCode: "",
        // ServiceProviderId: 4,
        // InvoiceRise: "",
        // InvoiceTypeId: 0,
        // InvoiceStatus: null,
        // InvoiceCategory: "",
        // InvoiceFilePath: "",
      },
    };
  },
  methods: {
    handleView(e) {
      console.log(e);
      this.viewData = { ...e };
      this.viewDialogVisible = true;
    },
    handleEdit(e) {
      console.log(e);
      this.$store.commit("setData", { [this.api.entity + e.Id]: e });
      this.$store.commit("setData", { [this.api.entity]: this.formKeys });
      this.$router.push({
        path: "/invoice_edit",
        query: {
          api: "/api/invoice/Edit",
          id: e.Id,
        },
      });
    },
    onSearch(e) {
      this.$refs.table.getData(e);
    },
  },
};
</script>

<style></style>
